package com.hundsun.fcp.common.utils;

import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Build;

import com.hundsun.fcp.R;

public class CommonDialog {
	public static void showAlert(final Context context, final int titleId,
			final int infoId,
			final DialogInterface.OnClickListener positiveClickListener
			,final DialogInterface.OnClickListener negativeClickListener) {
		final Dialog ab = getBuilder(context)
				.setCancelable(false)
				.setTitle(titleId)
				.setMessage(infoId)
				.setPositiveButton(R.string.btnOk, positiveClickListener)
				.setNegativeButton(R.string.btnCancel, negativeClickListener)
				.create();
		ab.show();
	}
	
	public static void showAlert(final Context context, final int titleId,
			final int infoId,final int positiveBtnStrId,int negativebtnStrId,
			DialogInterface.OnClickListener positiveBtnClick,
			final DialogInterface.OnClickListener negativeBtnClick) {
		final Dialog ab = getBuilder(context)
				.setCancelable(false)
				.setTitle(titleId)
				.setMessage(infoId)
				.setPositiveButton(positiveBtnStrId, positiveBtnClick)
				.setNegativeButton(negativebtnStrId, negativeBtnClick)
				.create();
		ab.show();
	}
	
	public static void showSettingPattern(Context context,DialogInterface.OnClickListener negativeBtnClick,
			 DialogInterface.OnClickListener positiveBtnClick,DialogInterface.OnClickListener neutralBtnClick){
		AlertDialog.Builder localBuilder = getBuilder(context) ;
	      localBuilder.setTitle(R.string.app_name);
	      localBuilder.setMessage(R.string.prompt_lockpattern);
	      localBuilder.setNegativeButton(R.string.no_prompt_again, negativeBtnClick);
	      localBuilder.setPositiveButton(R.string.confirm, positiveBtnClick);
	      localBuilder.setNeutralButton(R.string.cancel, neutralBtnClick);
	      localBuilder.create().show();
	}

	@TargetApi(Build.VERSION_CODES.HONEYCOMB)
	public static Builder getBuilder(Context context) {
		Builder builder;
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
			builder = new AlertDialog.Builder(context,
					AlertDialog.THEME_HOLO_LIGHT);
		} else {
			builder = new AlertDialog.Builder(context);
		}

		return builder;
	}
}
